<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	template="./../template.xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">
	
	<ui:define name="tituloJanela">
		<title>Cadastrar Novo Servidor</title>
	</ui:define>

	<ui:define name="tituloCima">
		<h1>Cadastrar Novo Servidor</h1>
	</ui:define>
	
	<ui:define name="conteudo">
		<h:form id="tabelaForm">
			<p:messages></p:messages>
			<p:panel header="Cadastrar Servidor">
			<h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
			
				<h:outputLabel value="Nome: "/>
				<p:inputText value="#{servidorMB.servidor.nome}" required="true" 
				requiredMessage="Entre com o nome completo do servidor." size="35"/>
				
				<h:outputLabel value="Matrícula: "/>
				<p:inputText value="#{servidorMB.servidor.matricula}" required="true" 
					requiredMessage="Entre com a matrícula do servidor (apenas números)." size="35">
					<f:convertNumber integerOnly="true" minIntegerDigits="6" pattern="#"/>
				</p:inputText>
				
				<h:outputLabel value="E-mail: "/>
				<p:inputText value="#{servidorMB.servidor.email}" required="true" 
					requiredMessage="Entre com o email do servidor." validatorMessage="E-mail inválido." size="35">
					<f:validateRegex pattern="^[-+.\w]{1,64}@[-.\w]{1,64}\.[-.\w]{2,6}$"></f:validateRegex>
				</p:inputText>
				
				<h:outputLabel value="Setor: " />  
		        <p:selectOneMenu value="#{servidorMB.servidor.setor}" effect="fade" required="true"
		        	requiredMessage="Selecione o setor do servidor." style="width: 358px;" >  
		            <f:selectItem itemLabel="Selecionar" itemValue=""/>  
		            <f:selectItems value="#{setorMB.setorItens}"/>
		        </p:selectOneMenu>
				<p:spacer  rendered="#{servidorMB.isEdicao()}"/>
				<p:inputText value="#{servidorMB.nomeSetor}" disabled="true" rendered="#{servidorMB.isEdicao()}"
					size="35"/>
				
				<h:outputLabel></h:outputLabel>
									
			</h:panelGrid>
			</p:panel>
			<br/>
			<p:commandButton action="#{servidorMB.adicionaServidor}" value="Salvar" update=":tabelaForm" ajax="false"/>
		</h:form>
	</ui:define>
</ui:composition>